Skip to content

Conversation

@JohananOppongAmoateng
Copy link
Contributor

When using Django's natural key serialization with :django-admin:dumpdata and
:django-admin:loaddata, polymorphic models require special handling.
polymorphic.managers.PolymorphicQuerySet.non_polymorphic in
get_by_natural_key() for polymorphic models. Without this, deserialization fails
when loading new objects because polymorphic queries try to fetch incomplete objects.

Closes #517

@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.44%. Comparing base (0d30c86) to head (692eb37).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #790   +/-   ##
=======================================
  Coverage   83.44%   83.44%           
=======================================
  Files          26       26           
  Lines        1649     1649           
  Branches      264      264           
=======================================
  Hits         1376     1376           
  Misses        207      207           
  Partials       66       66           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JohananOppongAmoateng JohananOppongAmoateng self-assigned this Jan 8, 2026
@bckohan
Copy link
Collaborator

bckohan commented Jan 9, 2026

With the changes in #814 this documentation is no longer necessary. dumpdata managers will already be marked as non_polymorphic() so there is no special requirement to make your get_by_natural_key() calls non_polymorphic.

@bckohan bckohan closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

please document how to deserialize by natural key

2 participants